Skip to content

perf(docker): optimize Dockerfiles with BuildKit cache for faster rebuilds#109

Merged
fujikosu merged 7 commits intomainfrom
feat/introduce-buildkit-cache
Dec 16, 2025
Merged

perf(docker): optimize Dockerfiles with BuildKit cache for faster rebuilds#109
fujikosu merged 7 commits intomainfrom
feat/introduce-buildkit-cache

Conversation

@fujikosu
Copy link
Copy Markdown
Member

Purpose

This pull request improves the Dockerfiles and devcontainer configurations for the notebooks, sample CPU, and sample PyTorch GPU projects. The main goals are to optimize build performance using BuildKit cache mounts, standardize development tool installation, and enhance clarity and maintainability of the devcontainers with additional comments.

Build optimization and environment improvements:

  • All Dockerfiles now use BuildKit cache mounts for both apt and pip, which significantly speeds up rebuilds by caching package downloads.
  • The PIP_CACHE_DIR environment variable is set in all containers to centralize and persist pip cache, further improving pip install performance.

Configuration and documentation enhancements:

  • Each devcontainer.json now includes a descriptive name field for easier identification in development environments.
  • Comments throughout the Dockerfiles have been clarified and expanded to improve maintainability and onboarding for new developers.

Does this introduce a breaking change?

  • Yes
  • No

Author pre-publish checklist

  • No PII in logs or output
  • Made corresponding changes to the documentation
  • All new packages used are included in requirements.txt
  • Functions use type hints, and there are no type hint errors

Pull Request Type

What kind of change does this Pull Request introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes
  • Experiment notebook

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes Docker build performance across three devcontainer configurations by implementing BuildKit cache mounts for package managers and improving documentation clarity. The changes standardize the build process for the notebooks, sample CPU, and sample PyTorch GPU projects.

Key changes:

  • Implements BuildKit cache mounts for both apt and pip installations to accelerate rebuilds
  • Adds descriptive name fields to devcontainer.json files for better IDE identification
  • Fixes spelling errors in comments ("pacakages" → "packages", "accesible" → "accessible", "depencencies" → "dependencies")

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json Adds descriptive name field for easier devcontainer identification
src/sample_pytorch_gpu_project/.devcontainer/Dockerfile Implements BuildKit cache mounts for apt/pip, sets PIP_CACHE_DIR, improves comments, fixes spelling
src/sample_cpu_project/.devcontainer/devcontainer.json Adds descriptive name field for easier devcontainer identification
src/sample_cpu_project/.devcontainer/Dockerfile Implements BuildKit cache mounts for apt/pip, sets PIP_CACHE_DIR, improves comments, fixes spelling
notebooks/.devcontainer/devcontainer.json Adds descriptive name field for easier devcontainer identification
notebooks/.devcontainer/Dockerfile Implements BuildKit cache mounts for apt/pip, sets PIP_CACHE_DIR, improves comments, fixes spelling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sample_pytorch_gpu_project/.devcontainer/Dockerfile Outdated
Comment thread notebooks/.devcontainer/Dockerfile Outdated
Comment thread src/sample_cpu_project/.devcontainer/Dockerfile Outdated
Comment thread src/sample_cpu_project/.devcontainer/Dockerfile Outdated
fujikosu and others added 2 commits December 14, 2025 06:59
… to avoid runtime permission issues for non-root user
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sample_cpu_project/.devcontainer/Dockerfile Outdated
Comment thread notebooks/.devcontainer/Dockerfile Outdated
Comment thread notebooks/.devcontainer/Dockerfile Outdated
Comment thread src/sample_pytorch_gpu_project/.devcontainer/Dockerfile Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fujikosu fujikosu requested a review from junkataoka December 15, 2025 01:43
Comment thread src/sample_cpu_project/.devcontainer/Dockerfile
@junkataoka
Copy link
Copy Markdown

Great refactoring effort!! Mostly minor comments, so I'll leave it to you to decide you think they should be addressed.

Also, each requirements file has its own COPY + RUN pair. This is good for cache invalidation granularity, but consider whether all three files change at different rates. If they typically change together, I think combining them could reduce layer count. If they always change together, consider combining into a single COPY + RUN to reduce layers. Otherwise, no change needed for the req file strcture!

Comment thread src/sample_cpu_project/.devcontainer/Dockerfile Outdated
Comment thread notebooks/.devcontainer/Dockerfile
Comment thread src/sample_pytorch_gpu_project/.devcontainer/Dockerfile
Comment thread src/sample_pytorch_gpu_project/.devcontainer/Dockerfile Outdated
@fujikosu
Copy link
Copy Markdown
Member Author

@junkataoka I addressed all your comments co could you check this and approve or give feedback?

Copy link
Copy Markdown

@junkataoka junkataoka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for addresing my comments!!

@fujikosu fujikosu merged commit 8d4534f into main Dec 16, 2025
2 checks passed
@fujikosu fujikosu deleted the feat/introduce-buildkit-cache branch December 16, 2025 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants